<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加</title>
    <%--需要引入各种css、js、jquery的插件--%>
    <script type="text/javascript" src="easyui1.7/jquery.min.js"></script>
    <script type="text/javascript" src="easyui1.7/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="easyui1.7/locale/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" type="text/css" href="easyui1.7/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui1.7/themes/icon.css"/>
</head>
<body>
<form action="add" method="post" enctype="multipart/form-data" onsubmit="return checkForm()">
    游戏名称: <input type="text" required="required" name="name" id="name" ><span id="sp1"></span><br>
    是否氪金: <input type="radio" name="money" class="money" value="是">是<input type="radio" class="money" name="money" value="否">否
    <br>
    游戏logo: <input type="file" required="required" id="img" name="imgFile"><br>
    研发公司:
    <select name="a" id="a" onchange="getB()">
        <option>请选择</option>
    </select>
    <select name="b" id="b">
        <option>请选择</option>
    </select>
    <br>
    <input type="submit" value="提交">
    <input type="reset" value="重置">
</form>
</body>
<script>
    $.post("findA",{"cid":0},function (data) {
        for (var i in data){
            $('#a').append("<option class='a' id="+data[i].id+">"+data[i].cname+"</option>")
        }
    })
    function getB() {
        var cid = $('.a:selected').attr("id");
        $.post("findA",{"cid":cid},function (data) {
            $('#b').empty();
            $('#b').append("<option>请选择</option>");
            for (var i in data){
                $('#b').append("<option class='b' id="+data[i].id+">"+data[i].cname+"</option>")
            }
        })
    }
    function checkForm() {
        debugger
        var name=$('#name').val();
        var money=$('.money:checked').attr("value")
        var a = $('.a:selected').val()
        var b = $('.b:selected').val()
        if (name!=null&&name!=undefined&&name!=""){
            $.post("checkName",{"name":name},function (data) {
                if (data=="true"){
                    $('#sp1').text("游戏名称不能重复")
                }else{
                    $('#sp1').text("")
                }
            })
        }
        if (money==null||money==undefined||money==""||a==null||a==undefined||a==""||b==null||b==undefined||b==""){
            return false;
        }else{
            return true;
        }
    }
</script>
</html>
